<%= javascript_include_tag :defaults %>

<h1>Restful Thread Messages</h1>

<p><%= rtm_menu -%></p>

<p>
  <h3><%= @thread.subject %></h3>
  between: <%= @thread.receiver_ids %> and <%= @thread.sender.login %>
</p>

<div id="messages">
  <% unless @messages.size == @thread.messages.size -%>
    You deleted this thread.
    <%= link_to 'Show deleted messages', { :show_del => 1, :type => params[:type] }%>
  <% end -%>
  <% unless @thread.thread_id == @thread.id -%>
    This message is branched from a previous thread. 
    Show thread history.
  <% end -%>
  <%= render :partial => 'message', :collection => @messages %>
</div>

<p><div id="notice"><%= flash[:notice] %></div></p>

<% form_remote_for Message.new(:thread_id => @thread.id, :subject => "Re: #{@thread.subject}"), :url => messages_path, :html => {:id => 'message_form'} do |f| -%>
  <%= f.hidden_field :thread_id %>
  <%= f.hidden_field :subject %>
  <p>
    Reply: <br />
    <%= f.text_area :body, :rows => 4 %>
  </p>
  <p>
    <%= f.submit 'Send' %>
    <%= link_to 'Delete', message_path(@thread, :type => params[:type]), :method => :delete %>
  </p>
<% end -%>
